//
// Created by bing on 2021/7/10.
//

#include "VirtualFunctionDemo.h"

int VirtualFunctionDemo::main() {
    Person person("KeQing");
    Student student("Babara", "Mengde");
    CollegeStudent collegeStudent("Windy", "MengDe", "Babara");

    Person *p;

    p = &person;
    p->hello();

    p = &student;
    p->hello();

    p = &collegeStudent;
    p->hello();
}

void Person::hello() {
    cout << "person name is:" << name << endl;
}


void Student::hello() {
    cout << "student name is:" << name << endl;
}


void CollegeStudent::hello() {
    cout << "collegeStudent name is:" << name << endl;
}
